#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 100010;
int n;
int q[N];
int main()
{
    cin >> n;
    int x, y;
    while(n --)
    {
        cin >> x >> y;
        q[x] = q[x] + y;
    }
    int index = 0, res = 0;
    for(int i = 1; i < N; i ++)
    {
        if(q[i] > res)
        {
            res = q[i];
            index = i;
        }
    }
    cout << index << ' ' << res << endl;
    return 0;
}